import { reqProductList } from '@/api';

const state = {
    productList: {}
}
const mutations = {
    RECEIVE_PRODUCTlIST(state, data) {
        state.productList = data
    }
}
const actions = {
    async getProductList({ commit }, searchParams = {}) {
        const data = await reqProductList(searchParams);
        if (data.code === 200) {
            commit('RECEIVE_PRODUCTlIST', data.data)
        }
    }
}
const getters = {
    attrsList(state) {
        return state.productList.attrsList || []
    },
    trademarkList(state) {
        return state.productList.trademarkList || []
    },
    total(state) {
        return state.productList.total || 0
    }
}

export default {
    state,
    mutations,
    actions,
    getters
}